package com.xcw.test.caozuo;

import java.util.Scanner;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author bhx
 * @Class P10_
 * @date 2022/11/13 3:27
 * @Description TODO
 */
public class P11_ {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(100, 1000, 180, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
        Scanner sc =new Scanner(System.in);
        int n,m;
        do{
            n =sc.nextInt();
            if(n>=1000000||n<=0){
                System.out.print("您输入的红牌数n不在区间内，请重新输入：\r\n");
            }
        }while(n>=1000000||n<=0);

        do{
            m =sc.nextInt();
            if(m>=1000000||m<=0){
                System.out.print("您输入的蓝牌数m不在区间内，请重新输入:\r\n");
            }
        }while(m>=1000000||m<=0);
        AtomicInteger count = new AtomicInteger();
        for (int i = 1; i <= n; i++) {
            int finalI = i;
            int finalM = m;
            threadPoolExecutor.execute(()->{
                for (int j = 1; j <= finalM; j++) {
                    if ((finalI + j) % 5 == 0) {
                        count.getAndIncrement();
                    }
                }
            });

        }
        threadPoolExecutor.shutdownNow();
        long end = System.currentTimeMillis();
        System.out.println(count.get());
        System.out.println("耗时：" + (end -start)/ 1000 + "s");
    }

    public static void setNum(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i] = i+1;
        }
    }
    public static int match5bei(int num, int[] arr){
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if ((num + arr[i])%5 == 0){
                count++;
            }
        }
        return count;
    }
}
